package Scuttlebutt;

import java.awt.event.*;
import javax.swing.*;
import java.awt.Point;

public class FileTransferTablePopupMenu extends JPopupMenu 
{
	public class Remove extends JMenuItem implements ActionListener{
		FileTransferTable table = null;
		int x = 0;
		int y = 0;
		public Remove(FileTransferTable table, int x, int y){
			super("Remove");
			this.table = table;
			this.x = x;
			this.y = y;
			addActionListener(this);
		}
		public void actionPerformed(ActionEvent a0)
		{
			((DownloadTableModel)table.getModel()).remove(table.rowAtPoint(new Point(x, y)));
			table.updateUI();
		}
	}
	
	public FileTransferTablePopupMenu(FileTransferTable table, int x, int y)
	{
		add(new Remove(table, x, y));
		if(((DownloadTableModel)table.getModel()).canRemove(table.rowAtPoint(new Point(x, y)))){
			((JMenuItem)getComponent(0)).setEnabled(true);
		}else{
			((JMenuItem)getComponent(0)).setEnabled(false);
		}
	}
}

